function average(avg);
% perform average on the specified data sets
% Both the voltage and the current are averaged over the data
%
%
global CURRENT VOLTAGE WCHAN
va=[];
ia=[];

if(avg <= 1)
	va=VOLTAGE;
	ia=CURRENT;
 	return;
end;
[recs, dsize] = size(VOLTAGE); % assume current and voltage are same size
k=1;
for j=1:avg:recs-avg
	va(k,:) = mean(VOLTAGE([j:j+avg-1],:));
	ia(k,:) = mean(CURRENT([j:j+avg-1],:));
	k=k+1;
end; 
VOLTAGE = va;
CURRENT = ia;
return;
